/**
 * Created by 静龄 on 2015/11/11.
 */


/**
 * Created by ���� on 2015/11/6.
 */
!
    function(window){
        Rcheck={"version":"1.0",authon:"darkness"};
        window.Rcheck=Rcheck;
    }(window),


    function(Rcheck){

        Rcheck.checknull=function(str){
            if (str.length == 0)
            {
                return true;
            }else{
                var regu = "^[ ]+$";
                var re = new RegExp(regu);
                if(re.test(str)){
                    return true;
                }
                return false;
            }
        };


        Rcheck.getLength=function(str){



            var realLength = 0, len = str.length, charCode = -1;

            for (var i = 0; i < len; i++) {

                charCode = str.charCodeAt(i);

                if (charCode >= 0 && charCode <= 128) realLength += 1;

                else realLength += 2;

            }

            return realLength;
        };

        Rcheck.checklength=function(str,maxlength){
            if(this.getLength(str)>maxlength){
                return true;
            }else{
                return false;
            }
        };

        Rcheck.checknum=function(str){
            return !/^\d+$/.test(str);
        };
        Date.prototype.Format = function(fmt)
        { //author: meizz
            var o = {
                "M+" : this.getMonth()+1,                 //月份
                "d+" : this.getDate(),                    //日
                "h+" : this.getHours(),                   //小时
                "m+" : this.getMinutes(),                 //分
                "s+" : this.getSeconds(),                 //秒
                "q+" : Math.floor((this.getMonth()+3)/3), //季度
                "S"  : this.getMilliseconds()             //毫秒
            };
            if(/(y+)/.test(fmt))
                fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
            for(var k in o)
                if(new RegExp("("+ k +")").test(fmt))
                    fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
            return fmt;
        }

        Rcheck.changedate=function(time){
            if(time){
                return new Date(parseInt(time) * 1000).Format("yyyy-MM-dd hh:mm:ss");
            }else{
                return "";
            }
        }

        Rcheck.checkMail=function(str){
            return !(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(str));
        }


    }(Rcheck);

